package com.dkd.http.controller;

import com.dkd.entity.SkuClassEntity;
import com.dkd.entity.SkuEntity;
import com.dkd.entity.dto.VmPageDto;
import com.dkd.entity.vo.SkuClassPageVo;
import com.dkd.entity.vo.SkuPageVo;
import com.dkd.service.SkuClassService;
import com.dkd.service.SkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 商品类型管理
 * 只有管理员角色才能对商品写操作，使用权限框架细粒度控制
 */
@RestController
@Api(tags = "商品类型管理")
@RequestMapping("/skuClass")
@RequiredArgsConstructor
@Slf4j
public class SkuClassController {
    private final SkuClassService skuClassService;
    @GetMapping("/search")
    @ApiOperation("商品类型搜索")
    public SkuClassPageVo searchSku(VmPageDto vmPageDto){
        return skuClassService.searchSku(vmPageDto);
    }

    @PutMapping("/{classId}")
    @ApiOperation("修改商品类型")
    public boolean updateSkuClass(@RequestBody SkuClassEntity skuClassEntity){
        return skuClassService.updateById(skuClassEntity);
    }
    @DeleteMapping("/{classId}")
    @ApiOperation("删除商品类型")
    public boolean DeleteSkuClass(@PathVariable("classId") Integer classId){
        return skuClassService.removeById(classId);
    }
    @PostMapping
    @ApiOperation("新增商品类型")
    public boolean AddSkuClass(@RequestBody SkuClassEntity skuClassEntity){
        return skuClassService.save(skuClassEntity);
    }



}
